package 优先算法.模拟.替换所有的问号;

/**
 * https://leetcode.cn/problems/replace-all-s-to-avoid-consecutive-repeating-characters/description/
 */
public class Main {
    public static void main(String[] args) {
        Solution so = new Solution();
        String str = "?zs";
        String rel = so.modifyString(str);
        System.out.println(rel);
    }
}
class Solution {
    public String modifyString(String ss) {
        char[] s = ss.toCharArray();
        int n = s.length;
        for(int i = 0; i < n;i++){
            if(s[i] == '?'){
                for(char j = 'a';j < 'z';j++){
                    if((i==0 || s[i-1]!=j) && (i==n-1 || s[i+1]!=j)){
                        s[i] = j;
                        break;
                    }
                }
            }
        }
        return String.valueOf(s);
    }
}
